package com.qbw.app.model;

import androidx.databinding.Bindable;

import com.lib.util.ResUtil;
import com.qbw.app.R;

import java.io.Serializable;

/**
 * @author QBW
 * @date 2019/8/29
 */
public class Coolant extends BaseModel implements Serializable {

    public static final double HIGH = 90D;

    public static final String NORMAL = "1";
    public static final String NO_DATA = "0";
    public static final String EXCEPTION = "-1";

    private long lastUpdateTime;
    private String state = NO_DATA;
    private String value;
    private String vehicleCode;
    private Vehicle vehicle;
    private int limit;

    @Bindable
    public long getLastUpdateTime() {
        return lastUpdateTime;
    }

    public void setLastUpdateTime(long lastUpdateTime) {
        this.lastUpdateTime = lastUpdateTime;
    }

    @Bindable
    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    @Bindable
    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public String getVehicleCode() {
        return vehicleCode;
    }

    public void setVehicleCode(String vehicleCode) {
        this.vehicleCode = vehicleCode;
    }

    public Vehicle getVehicle() {
        return vehicle;
    }

    public void setVehicle(Vehicle vehicle) {
        this.vehicle = vehicle;
    }

    @Bindable
    public int getLimit() {
        return limit;
    }

    public int getStatusText() {
        return EXCEPTION.equals(state) ? R.string.high_temperature : R.string.voltage_normal;
    }

    public int getStatusDrawable() {
        return EXCEPTION.equals(state) ? R.drawable.coolant_exception : R.drawable.coolant_normal;
    }

    public int getWaveBg() {
        int d = R.drawable.coolant_wave_bg_normal;
        if (EXCEPTION.equals(state)) {
            d = R.drawable.coolant_wave_bg_exception;
        }
        return d;
    }

    public int getWaveFrontColor() {
        int c = ResUtil.getColor(R.color.vehicle_coolant_wave_front_normal_color);
        if (EXCEPTION.equals(state)) {
            c = ResUtil.getColor(R.color.vehicle_coolant_wave_front_exception_color);
        }
        return c;
    }

    public int getWaveBehindColor() {
        int c = ResUtil.getColor(R.color.vehicle_coolant_wave_behind_normal_color);
        if (EXCEPTION.equals(state)) {
            c = ResUtil.getColor(R.color.vehicle_coolant_wave_behind_exception_color);
        }
        return c;
    }

    public static class Response extends BaseResponse<Coolant> {}
}
